package com.mesSystem.service.impl.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mesSystem.entity.Employee;
import com.mesSystem.entity.WorkstationAndEmployee;
import com.mesSystem.mapper.EmployeeMapper;
import com.mesSystem.mapper.WorkstationAndEmployeeMapper;
import com.mesSystem.service.impl.EmployeeService;
import com.mesSystem.service.impl.WorkstationAndEmployeeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements EmployeeService {

    @Autowired
    WorkstationAndEmployeeMapper workstationAndEmployeeMapper;
    /**
     * 通过员工id获取员工姓名
     * @param employeeId
     * @return
     */
    public String getEmployeeName(Long employeeId) {
        // 代简化！！！
        String employeeName = getById(employeeId).getEmployeeName();
        return employeeName;
    }

    @Override
    public String removeById(Long employeeId) {
        String status = getById(employeeId).getStatus();
        if ("在岗".equals(status)) {
            return "员工在岗，不可删除";
        }
        removeById(employeeId);
        log.info("删除员工：{}",employeeId.toString());
        return "删除成功";
    }

}
